CPP=g++
CC = gcc
MAKE=make

NAME = pland
C_FILES = src/mongoose.c src/untar.c
CPP_FILES = src/control.cpp src/main.cpp src/webfrontend.cpp

CPP_OBJECTS	= $(CPP_FILES:src/%.cpp=%.o)
C_OBJECTS     = $(C_FILES:src/%.c=%.o)

COMPILE_FLAGS =  -I ../libpipc/lib/ -I../libpland/lib/ -I../tinyxml/ -I../libkport2/lib/ -O2 -rdynamic -fpic
LINK_FLAGS =  -o $(NAME) -lboost_thread -L../build/ -ltinyxml  -lpthread -fPIC -Wl,--rpath,. -rdynamic -ldl -lboost_filesystem -lboost_system  -Wl,--no-whole-archive -lpland -lpipc -lkport2

all: bin

system: bin
	cp $(NAME) ../build/
	cp -R resource/ ../build
	rm -rf ../build/resource/.svn

%.o: src/%.cpp
	$(CPP) $(COMPILE_FLAGS) -c -o $@  $< 

%.o: src/%.c
	$(CC) $(COMPILE_FLAGS) -c -o $@  $<

bin: $(CPP_OBJECTS) $(C_OBJECTS)
	$(CPP) $(CPP_OBJECTS) $(C_OBJECTS) -o $(NAME) $(LINK_FLAGS)

.PHONY	: clean open

clean:
	rm -rf *.o $(NAME) log.txt
open:
	geany  src/*.cpp lib/*.hpp &
